{% extends 'base.twig' %}
{% block style %}
    <style>
        .table thead tr th{
            height:30px; line-height: 30px; text-align: center;}
        .table tbody tr td{
            height:30px; line-height: 30px; text-align: center;}
    </style>
    <link href="template/plugins/pnotify/css/pnotify.custom.css" rel="stylesheet" type="text/css">
    <script src="template/plugins/pnotify/js/pnotify.custom.js" type="text/javascript"></script>
{% endblock %}
{% block content %}
<section id="main-content">
    <section class="wrapper">
        <div class="row mt">
            <div class="col-lg-12">
                <div class="content-panel">
                    <h4><i class="fa fa-directory"></i>  用户组  {% if admin.is_admin %}<a class="btn btn-success pull-right addGroup" href="javascript:void(0);" addGroup> 增加用户组</a>{% endif %}</h4>
                    <section id="unseen">
                        <table class="table table-bordered ">
                            <thead>
                            <tr>
                                <th>id</th>
                                <th width="20%">用户名称</th>
                                <th width="50%">备注</th>
                                <th>添加时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for g in goodsList %}
                                <tr class="{% if g.is_del==1 %}bg-danger{% endif %}">
                                    <td>{{ g.user_group_id }}</td>
                                    <td>{{ g.title }}</td>
                                    <td>{{ g.remark }}</td>
                                    <td>{{ g.create_at }}</td>
                                    <td>
                                        {% if admin.is_admin %} <a class="btn btn-primary edit" href="javascript:void(0);" data-id="{{ g.user_group_id  }}"><i class="fa fa-edit"></i> 编辑</a> {% endif %}
                                        </td>
                                </tr>
                            
                            {% endfor %}
                            </tbody>
                        </table>
    
                        <div class="text-center">
                            {{ pageHtml|raw }}
                        </div>
                    </section>
                </div>
            </div>
        </div>
    </section>
</section>
    <script src="template/plugins/dialog/dist/dialog-plus-min.js?"></script>
    <script type="text/javascript">
        highlight_subnav('userGroup.php?');
        $('.addGroup').bind('click',function(){
            var obj=$(this);
            var _url= "userGroup.php?act=add";
            dialog({
                id:'edit',
                title:'增加用户组',
                url:_url,
                width:600,
                height:700,
                data:obj
            }).showModal();
        });
        $('.edit').bind('click',function(){
            var obj=$(this),data_id = $(this).attr('data-id');

            var _url= "userGroup.php?act=edit&id="+data_id;
            dialog({
                id:'edit',
                title:'编辑用户组',
                url:_url,
                width:600,
                height:500,
                data:obj
            }).showModal();
        });
        function ModalClose(){
            dialog.get('edit').close();
            new PNotify({
                title: '成功！',
                text: '操作成功',
                type: 'success',
                addclass: 'stack-bar-top'
            });
            setTimeout(function () {
                location.reload();
            },2000)
        }
    </script>
{% endblock %}
